export const getNewDateArr = (arr) => {
  arr.sort((a, b) => new Date(b.createTime) - new Date(a.createTime));
  // 按照createTime分组形成新数组
  const newArray = arr.reduce((acc, current) => {
      const date = current.createTime.split(' ')[0];
      if (!acc[date]) {
          acc[date] = [];
      }
      acc[date].push(current);
      return acc;
  }, {});
  return newArray
}

// 调用 getNewDateArr 函数并获取最新两个日期对应的数据
export const getLatestTwoData = (arr) => {
    const groupedData = getNewDateArr(arr);
    const dates = Object.keys(groupedData).sort((a, b) => new Date(b) - new Date(a));
    const latestTwoDates = dates.slice(0, 2);
    const latestTwoData = latestTwoDates.reduce((result, date) => {
        result[date] = groupedData[date];
        return result;
    }, {});
    return latestTwoData;
};